<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page
	import="b1w1nn1ng.crossf1t.gui.*,java.util.*,java.sql.*,b1w1nn1ng.crossf1t.business.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Profile</title>
<jsp:include page="/detectBrowser.jsp" />
</head>
<body>

	<%
		User user = (User) session.getAttribute("user");
		user = User.getUserById(user.getId());
		session.setAttribute("user", user);
		ArrayList<Friend> fList = Friend.getSortedList(user.getFriends());
	%>

	<div id="container">
		<jsp:include page="/navbar.jsp" />
		<h1>View Friends</h1>
		<hr />
		
		<div class="datatableframe">
			<table class="datatable">
				<%
					boolean odd = true;
					//System.out.println("username: " + user.getUsername());
					//System.out.println("This print statemnt brought to you by friendsView.jsp" + fList.size() + "User.getFriends:" + user.getFriends());
					for (Friend friend : fList) {
						if (odd) {
							odd = false;
							out.println("<tr class = \"datatablealt\">");
						} else {
							odd = true;
							out.println("<tr>");
						}
						//System.out.println("EVERYTHING AFTER THIS!!!: " + friend + "this print line is located at friendsView.jsp. FIND ME ");
						if (friend != null) {
							/* out.println("<a href=\"profile.jsp?friendID="
									+ friend.getID() + "\"><td>"
									+ friend.getUser().getLastName() + ", "
									+ friend.getUser().getFirstName() + "</td></a>");
							out.println("</tr>"); */
							%>
							

								<td>
									<a class="friendsView" 	href="/crossfit/viewFriendsProfile.jsp?friendID=<%=friend.getID() %>">
										<%user.update(); %>
										<%= friend.getUser().getLastName() %>
										<%= friend.getUser().getFirstName() %> 
									</a>
								</td>
							</tr>
							<%
						}
					}
				%>
			</table>	
		</div>
	</div>
</body>
</html>